<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="produce_info" :rules="rules" label-width="100px" id="mvcfm">
          <div class="form-unit">
            <span class="mvc-title-left"> 设备备件详情 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="设备名称" prop="">
                  {{produce_info.produce_name}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="设备编号" prop="">
                  {{produce_info.produce_num}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="设备型号" prop="">
                  {{produce_info.produce_model}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="设备规格" prop="">
                  {{produce_info.produce_norm}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="生产厂家" prop="">
                  {{empty}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="popSpareAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加备件</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 备件信息 </span>
          </div>
          <el-table :data="produce_backup">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_pb('&pbid='+scope.row.backup_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popSpareUp('&pbid='+scope.row.backup_id+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popSpareDetails('&pbid='+scope.row.backup_id+'')">查看明细</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备件名称" prop="backup_id">
              <template slot-scope="scope">
                <el-link @click="popSpareDetails('&pbid='+scope.row.backup_id+'')" type='primary'>{{scope.row.backup_name}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="备件型号" prop="backup_model">
            </el-table-column>
            <el-table-column label="设备规格" prop="backu_pnorm">
            </el-table-column>
            <el-table-column label="备件数量" prop="backup_count">
            </el-table-column>
            <el-table-column label="录入人" prop="username">
            </el-table-column>
          </el-table>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'备件信息'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="SpareAddVisible" append-to-body>
      <SpareAdd v-if="SpareAddVisible" ref="SpareAdd" :popparams="popparams"> </SpareAdd>
    </el-dialog>
    <el-dialog :visible.sync="SpareUpVisible" append-to-body>
      <SpareUp v-if="SpareUpVisible" ref="SpareUp" :popparams="popparams"> </SpareUp>
    </el-dialog>
    <el-dialog :visible.sync="SpareDetailsVisible" append-to-body>
      <SpareDetails v-if="SpareDetailsVisible" ref="SpareDetails" :popparams="popparams"> </SpareDetails>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SpareAdd from "@/views/mes/produce/SpareAdd";
  import SpareUp from "@/views/mes/produce/SpareUp";
  import SpareDetails from "@/views/mes/produce/SpareDetails";
  export default {
    name: 'SpareDet',
    components: {
      SpareAdd,
      SpareUp,
      SpareDetails,
    },
    props: ['popparams'],
    data() {
      return {
        SpareAddVisible: false,
        SpareAddValue: null,
        SpareAddDesc: null,
        SpareUpVisible: false,
        SpareUpValue: null,
        SpareUpDesc: null,
        SpareDetailsVisible: false,
        SpareDetailsValue: null,
        SpareDetailsDesc: null,
        vueparams: this.getVUEParams(""),
        produce_info: {
          produce_name: null,
          produce_num: null,
          produce_model: null,
          produce_norm: null,
        },
        produce_backup: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "D797D94B97264F339A7F3838BB343F64",
        name: "生产设备右菜单",
        selected: "备件信息"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/SpareDet/spareDet?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_pb(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/produce/SpareDet/d_pb?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popSpareAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SpareAddVisible = !this.SpareAddVisible;
      },
      popSpareUp(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SpareUpVisible = !this.SpareUpVisible;
      },
      popSpareDetails(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SpareDetailsVisible = !this.SpareDetailsVisible;
      },
    },
  }
</script>
